import matter from 'gray-matter';
const { test: hasFrontmatter } = matter;
/**
 * Injects content to the top of a file, but below the frontmatter
 */
export const injectToTopOfFile = (content, contentToInject) => {
    if (!hasFrontmatter(content))
        return contentToInject + `\n` + content;
    const { data: frontmatterData, content: contentWithoutFrontmatter } = matter(content);
    return matter.stringify(`\n` + contentToInject + `\n` + contentWithoutFrontmatter, frontmatterData);
};
